﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BTCairo
{
    public class Rect : Shape
    {
        int x, y, width, height;
        BasicShape rect;
        public Rect(CommonGraphics _comgra, int _x, int _y, int _width, int _height)
        {
            myCommonGraphic = _comgra;
            myCommonGraphic.MyInfoGraphic.x = _x;
            myCommonGraphic.MyInfoGraphic.y = _y;
            myCommonGraphic.MyInfoGraphic.widthShape = _width;
            myCommonGraphic.MyInfoGraphic.heightShape = _height;
            x = _x;
            y = _y;
            width = _width;
            height = _height;
        }
        public override InfoGraphic getInfoShape()
        {
            InfoGraphic info = myCommonGraphic.MyInfoGraphic;
            info.x = x;
            info.y = y;
            info.widthShape = width;
            info.heightShape = height;
            return info;
        }
        public override Shape CloneShape()
        {
            Rect temp = new Rect(myCommonGraphic.CloneCommonGraphic(), x, y, width, height);
            return temp;
        }
        public override Shape CloneShape(int plusX, int plusY)
        {
            //Rect temp = new Rect(myCommonGraphic.CloneCommonGraphic(), x+plusX, y+plusY, width, height);
            CommonGraphics g = myCommonGraphic.CloneCommonGraphic();
            InfoGraphic info = g.MyInfoGraphic;
            info.x = info.x + plusX;
            info.y = info.y + plusY;
            g.MyInfoGraphic = info;
            Rect temp = new Rect(g, info.x, info.y, info.widthShape, info.heightShape);
            return temp;
        }

        public override void Draw()
        {
            if (shadow != null)
                shadow.DoEffect(this);
            if (highlight != null)
                highlight.DoEffect(this);
            if (border != null)
                border.DoEffect(this);
            //rect = new BasicRect(myCommonGraphic, x, y, width, height);
            rect = new BasicRect(myCommonGraphic);
            rect.Draw();
        }
        public override void DrawEffect()
        {
            rect = new BasicRect(myCommonGraphic);
            //rect = new BasicRect(myCommonGraphic, x, y, width, height);
            rect.Draw();
        }

        //public override string ToString()
        //{
        //    return rect.ToString();
        //}

        public override void ParseXmlElement(System.Xml.XmlDocument doc, System.Xml.XmlElement root)
        {
            if (shadow != null)
                shadow.ParseXmlElement(doc, root);
            if (highlight != null)
                highlight.ParseXmlElement(doc, root);
            if (border != null)
                border.ParseXmlElement(doc, root);
            rect.ParseXmlElement(doc, root);
        }
    }
}


